#define PA_SAMPLE_TYPE  paFloat32

#include "portaudio.h"

class PortAudioInit
{
public:
  PortAudioInit()
  {Pa_Initialize();}
  ~PortAudioInit()
  {Pa_Terminate();}
  const char * deviceName() const;
};

typedef struct
{
  int frameIndex;  //sample array index
  int maxFrameIndex;
  int samplesPerFrame;
  float *recordedSamples;
}paRecData;

class recordStream
{
public:
  recordStream();
  ~recordStream();
  bool open(const PortAudioInit &i);
  bool close();
  bool audioInput(float &max, float &avg_abs, float& bestpeak_freq);
private:
  paRecData data;
  PortAudioStream *record_stream;
  double m_sample_rate;
};
